<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        .box{
            position: relative;
            width:600px;
            height:600px;
            background-color: #ff8500;
        }
        .inner{
            position: absolute;
            /*坐标的百分比是相当于父级元素的大小来说*/
            left:50%;
            top:50%;
          /*  margin-top:-50px;
            margin-left:-50px;*/
            /*平移*/
            transform:translate(-50%,-50%);


            width:100px;
            height:100px;
            background-color: darkblue;
        }
    </style>
</head>
<body>
<div class="box">
    <div class="inner"></div>
</div>
</body>
</html>